package cn.cas.mango.util.paramCheck;

import cn.cas.mango.dto.param.hot.HotMissionParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
public class HotMissionParamCheck {
  public static Map<String, Object> checkParam(HotMissionParam formData) {
    Map<String, Object> map = new HashMap<>();
    if (Strings.isBlank(formData.getRwnm())) {
      throw new IllegalStateException("rwnm 不可以为空");
    }
    if (Strings.isBlank(formData.getNms()))
      throw new IllegalStateException("nms 不可以为空");
    formData.setSimWeight(0.2);
    formData.setNmsArray(Arrays.asList(formData.getNms().split(",")).stream().map(x->x.trim()).collect(Collectors.toList()));

    log.info("Request param:{}", formData);
    map.put("isSuccess", "ok");
    map.put("formData", formData);
    return map;
  }
}
